﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.BannerEditViewModel>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Thêm banner
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
    Thêm mới banner
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
        <%= Html.Toolbar("Quay về", "/Banner", "back") %>
    </td>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("Create", "Banner", FormMethod.Post, new { id = "adminForm", enctype = "multipart/form-data" }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <table class="adminlist" width="100%">
        <tr>
            <th width="60%">Thông tin menu</th>
            <th width="60%">Liên kết với menu</th>
        </tr>
        <tr>
            <td>
                <table class="admintable" width="100%">
                    <tbody>
                        <tr>
                            <td class="key">
                                Tên banner (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextBoxFor(model => model.Banner.Name, new { @class = "required",style="width:300px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Ngày bắt đầu (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextBox("FromDate","", new { @class = "datepicker",style="width:90px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Ngày kết thúc (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextBox("ToDate","", new { @class = "datepicker", style = "width:90px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Link của banner
                            </td>
                            <td>
                                <%=Html.TextBoxFor(model => model.Banner.UrlClick, new {style="width:300px" })%>
                            </td>
                        </tr> 
                        <tr>
                            <td class="key">Ảnh banner</td>
                            <td><input type="file" name="bannerImage" id="bannerImage" /></td>
                        </tr>
                        <tr>
                            <td class="key">File flash</td>
                            <td><input type="file" name="bannerFlash" id="bannerFlash" /></td>
                        </tr>
                        <tr>
                            <td class="key">Ngôn ngữ</td>
                            <td><%=Html.DropDownList("Banner.LangCode", new SelectList(Model.LanguageCode, "Key", "Value").ToList(), "-- Chọn ngôn ngữ --", new { style = "width:148px" })%></td>
                        </tr>           
                        <tr>
                            <td class="key">
                                Trạng thái publish
                            </td>
                            <td>
                                <%= Html.RadioButton("Banner.PubYN", true, new { @checked = "checked" })%>
                                Hiển thị banner
                                <%= Html.RadioButton("Banner.PubYN", false)%>
                                Không hiển thị banner
                            </td>
                        </tr>
                        <tr>
                            <td class="key">
                                Độ ưu tiên (<font color="red">*</font>)
                            </td>
                            <td>
                                <%=Html.TextBox("Priority",null, new { @class = "required", style = "width:60px" })%>
                            </td>
                        </tr>
                        <tr>
                            <td class="key">Chọn vị trí (<font color="red">*</font>)</td>
                            <td><%=Html.DropDownList("PositionID", new SelectList(Model.Positions, "ID", "Name").ToList(), "-- Chọn vị trí --", new {@class="required", style="width:305px"})%></td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <input type="submit" id="btnSave" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                                <input type="reset" id="btnReset" value="Nhập lại" />
                            </td>
                        </tr>            
                    </tbody>
                </table>            
            </td>
            <td>
                <div style="width:300px; height:400px; overflow:scroll">
                <ul style="margin:0px; padding:0px">
                    <%foreach (var m in Model.Menus)
                      { %>
                      <li><%=Html.CheckBox("chkMenu"+m.ID) %><%=Html.Encode(m.Name) %></li>
                    <%} %>
                </ul>
                </div>
            </td>
        </tr>
    </table>
    
    <%}
  } %>

        <script type="text/javascript">
            $(document).ready(function() {
            $("#adminForm").validate({
				rules: {
				    Priority : {required : true, number : true},
					FromDate: "required",
					ToDate : "required",
				},
				messages: {
				    Priority :{required: "This field is required.!", number: "Character must is number .!."},
					FromDate: "This field is required.!",
					ToDate : "This field is required.!"
				} 
                });
            });
    
        var fileIndex = 1;
        var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1, '.swf': 1};
        function check_extension(filename, submitId) {
            var re = /\..+$/;
            var ext = filename.match(re).toString().toLowerCase();
            var submitEl = document.getElementById(submitId);
            if (hash[ext]) {
                submitEl.disabled = false;
                return true;
            } else {
            }
        }
       $.datepicker.setDefaults($.datepicker.regional['vi']);
            $(".datepicker").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                showOn: "button",
                buttonImage: "/Images/calendar.gif",
                buttonImageOnly: true,
                changeYear: true
            });       
                
        tinyMCE.init({
            mode: "exact",
            elements: "Article_ArticleContent",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
    </script>

</asp:Content>
